//
// Created by Jisam on 2024/6/18.
// 21点00分
#include <bits/stdc++.h>

using  namespace  std;

const int MANX = 505;
char str[MANX][MANX];
int vis[MANX][MANX];
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};
char arr[] = {'U','R','D','L'};
bool judge(int x,int y,char ch){
    return  str[x][y] == ch;
}
signed main (){
    int T;
    cin >> T;
    while(T -- ){
        int n,m;
        cin >> n >> m;
        for(int i = 1 ; i <= n ;  ++i){
            for (int j = 1; j <= m ; ++j) {
                cin >> str[i][j];

            }
        }
        if (str[1][m] != '.') {
            cout << "No\n";
            continue;
        }
        for(int i  = n ; i >= 1  ; i --){
            for(int j = m ; j >= 1 ; j--){
                if(str[i][j] == 'C'){
                    vis[i][j] = 1;
                   for(int l = 0 ; l < 4 ; l ++){
                       int  cnt = 0;
                       for(int k = 0; k < 4; ++k){
                           if (judge(i+dx[k],j+dy[k],arr[k + l % 4])){
                               cnt ++;
                               vis[ i+dx[k]][j+dy[k]] = 1;
                           }
                           vis[ i+dx[k]][j+dy[k]] = 1;
                           if (cnt == 2) { continue;}
                           vis[ i+dx[(k + 4 - 1) % 4] ][j+dy[(k + 4 - 1) % 4]] = 0;
                       }
                   }
                }
            }
        }

        int flag = 0;
        for(int i = 1 ; i <= n ;  ++i){
            for (int j = 1; j <= m ; ++j) {
                if(vis[i][j] != 1){
                    flag = 1;
                    break;
                }
            }
        }
        if (flag == 0) cout << "Yes";
        else cout << "No";

    }
    return  0;
}
